package com.ruoyi.web.controller.basedata;

import com.ruoyi.basedata.domain.TerminalsXb;
import com.ruoyi.basedata.service.IDwAreasService;
import com.ruoyi.basedata.service.ITerminalsXbService;
import com.ruoyi.basedata.wxentity.AreaTreaXBDosage;
import com.ruoyi.basedata.wxentity.AreaTreeTerminalInfo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.WeChatTableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 小档案Controller
 *
 * @author ruoyi
 * @date 2023-09-07
 */
@RestController
@RequestMapping("/api/basedata/terminalxb")
public class TerminalsXbController extends BaseController
{
    @Autowired
    private ITerminalsXbService terminalsXbService;


    @Autowired
    private IDwAreasService dwAreasService;

    /**
     * 查询小表用户区域昨日用量
     */
    @GetMapping("/getAreaTreeForMobile")
    public WeChatTableDataInfo getAreaTreeForMobile(@RequestParam(value = "areaId",required = false) Integer areaId,
                                                    @RequestParam(value = "operatorId",required = false) Integer operatorId)
    {
        PageDomain pageDomain = startWeChatPage();
        List<AreaTreaXBDosage> list = dwAreasService.getAreaTreeForMobile(areaId);
        return getWeChatDataTable(list,pageDomain);
    }


    /**
     * 查询区域下小表设备信息和实时数据信息
     */
    @GetMapping("/searchTerminalXB")
    @PreAuthorize("@ss.hasPermi('basedata:terminalxb:list')")
    public WeChatTableDataInfo searchTerminalXB(TerminalsXb terminalsXb)
    {
        PageDomain pageDomain = startWeChatPage();
        List<AreaTreeTerminalInfo> terminalsXbs1 = terminalsXbService.searchTerminalXB(terminalsXb);
        return getWeChatDataTable(terminalsXbs1,pageDomain);

    }



    @PreAuthorize("@ss.hasPermi('basedata:terminalxb:query')")
    @GetMapping("/GetTerminalInfoById")
    public WeChatTableDataInfo getInfo(@RequestParam("id") Long id)
    {
        PageDomain pageDomain = startWeChatPage();
        TerminalsXb terminalsXb = new TerminalsXb();
        terminalsXb.setId(id);
        List<TerminalsXb> terminalsXbs = terminalsXbService.selectTerminalsXbList(terminalsXb);
        return getWeChatDataTable(terminalsXbs,pageDomain);
    }


}
